package com.ruibang.glass.sale.controller;


import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ruibang.glass.sale.domain.req.GSaleReturnExchangeReq;
import com.ruibang.glass.sale.entity.GSaleOrderManagement;
import com.ruibang.glass.sale.entity.GSaleReturnExchangeOrder;
import com.ruibang.glass.sale.service.GSaleReturnExchangeOrderService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author mameng
 */
@Api(tags = "退换货单发货")
@RestController
@RequestMapping("/api/glass/sale/return/exchange/order")
public class GSaleReturnExchangeOrderController {
    @Autowired
    private GSaleReturnExchangeOrderService gSaleReturnExchangeOrderService;

    @PostMapping("list")
    @ApiOperation(value = "退换货单列表", response = ResultBody.class)
    public ResultBody list(@RequestBody GSaleReturnExchangeReq saleReturnExchangeReq) {
        return ResultBody.success(gSaleReturnExchangeOrderService.getPage(saleReturnExchangeReq));
    }

    @PostMapping("addGSaleReturnExchangeOrder")
    @ApiOperation(value = "增加", response = ResultBody.class)
    public ResultBody addGSaleReturnExchangeOrder(@RequestBody GSaleReturnExchangeOrder gSaleOrderManagement) {
        gSaleReturnExchangeOrderService.addGSaleReturnExchangeOrder(gSaleOrderManagement);
        return ResultBody.success();
    }

    @PostMapping("updateGSaleReturnExchangeOrder")
    @ApiOperation(value = "换货发货申请", response = ResultBody.class)
    public ResultBody updateGSaleReturnExchangeOrder(@RequestBody GSaleReturnExchangeOrder gSaleOrderManagement) {
        gSaleReturnExchangeOrderService.updateGSaleReturnExchangeOrder(gSaleOrderManagement);
        return ResultBody.success();
    }

    @GetMapping("getOne/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getGSaleReturnExchangeOrderOne(@PathVariable("id") String id) {
        return ResultBody.success(gSaleReturnExchangeOrderService.getGSaleReturnExchangeOrderOne(id));
    }

    @GetMapping("getById/{id}")
    @ApiOperation(value = "查看详情", response = ResultBody.class)
    public ResultBody getById(@PathVariable("id") String id) {
        return ResultBody.success(gSaleReturnExchangeOrderService.getGSaleReturnExchangeOrderOne(id));
    }


}
